-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #5122
base: master
Are you sure you want to change the base?
Solution #5122
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mind some issues - but it is all good overall 👍
const PRICE_OF_RENT = 40; | ||
let totalCost = days * PRICE_OF_RENT; | ||
const SHORT_TERM = 3; | ||
const SMALL_DISCOUNT = 20; | ||
const LONG_TERM = 7; | ||
const BIG_DISCOUNT = 50; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please declare const
s outside functions if possible - with your solution you re-declare these variables on each function call
if (days < LONG_TERM) { | ||
totalCost = totalCost - SMALL_DISCOUNT; | ||
|
||
return totalCost; | ||
} | ||
|
||
totalCost = totalCost - BIG_DISCOUNT; | ||
|
||
return totalCost; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to reassign totalCost
Just return what you need
if (days < LONG_TERM) { | |
totalCost = totalCost - SMALL_DISCOUNT; | |
return totalCost; | |
} | |
totalCost = totalCost - BIG_DISCOUNT; | |
return totalCost; | |
if (days < LONG_TERM) { | |
return totalCost - SMALL_DISCOUNT; | |
} | |
return totalCost - BIG_DISCOUNT; |
If you do this - you can change
let totalCost = days * PRICE_OF_RENT;
to
const totalCost = days * PRICE_OF_RENT;
No description provided.